package com.serviciosti.atenser.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import com.serviciosti.atenser.model.entity.Customer;
import com.serviciosti.atenser.repository.CustomerRepository;

/**
 * @author iXav
 *
 */
@Controller("customer")
@Scope("request")
public class CustomerManagedBean {
	
	@Autowired
	private CustomerRepository customerRepository;
	
	private String customerId;
	private String taxId;
	private String name;
	private String adresse;
	private String city;
	private String state;
	private String zip;
	private String phone;

	private List<Customer> customers;
	
	public void save(){
		Customer customer= new Customer(Integer.parseInt(taxId), name, adresse, city, state, zip, phone, null);
		customerRepository.save(customer);
	}

	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	public String getTaxId() {
		return taxId;
	}

	public void setTaxId(String taxId) {
		this.taxId = taxId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAdresse() {
		return adresse;
	}

	public void setAdresse(String adresse) {
		this.adresse = adresse;
	}
	
	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getZip() {
		return zip;
	}

	public void setZip(String zip) {
		this.zip = zip;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public List<Customer> getCustomers() {
		customers = (List<Customer>) customerRepository.getAll();
		return customers;
	}

	public void setCustomers(List<Customer> customers) {
		this.customers = customers;
	}
		
}
